import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CouponTemplateQuery, CouponTemplateVO, CouponTemplateForm, CouponTemplateSubmitForm } from './types';

/**
 * 查询优惠券模板列表
 * @param query
 * @returns {*}
 */
export const listTemplate = (query?: CouponTemplateQuery): AxiosPromise<CouponTemplateVO[]> => {
    return request({
        url: '/coupon/template/list',
        method: 'get',
        params: query
    });
};

/**
 * 查询优惠券模板详细
 * @param id
 */
export const getTemplate = (id: string | number): AxiosPromise<CouponTemplateVO> => {
    return request({
        url: '/coupon/template/' + id,
        method: 'get'
    });
};

/**
 * 新增优惠券模板
 * @param data
 */
export const addTemplate = (data: CouponTemplateSubmitForm) => {
    return request({
        url: '/coupon/template',
        method: 'post',
        data: data
    });
};

/**
 * 修改优惠券模板
 * @param data
 */
export const updateTemplate = (data: CouponTemplateSubmitForm) => {
    return request({
        url: '/coupon/template',
        method: 'put',
        data: data
    });
};

/**
 * 删除优惠券模板
 * @param id
 */
export const delTemplate = (id: string | number | Array<string | number>) => {
    return request({
        url: '/coupon/template/' + id,
        method: 'delete'
    });
}; 